package com.rest.demo.concurrent;

import java.time.LocalTime;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

/**
 * @author Administrator
 * @decription
 * @Date 2018-01-31 15:11
 */
public class TimerDemo {
    public static void main(String[] args) {
        do {
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    System.out.println("---boom---");
                }
            },1000,2000);

            //打印秒钟，一秒输出一次,用来方便观察的
            while(true) {
                System.out.println(LocalTime.now().getSecond());
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch(Exception e) {
                    e.printStackTrace();
                }
            }
        } while (LocalTime.now().equals(LocalTime.of(15,30,30)));
    }
}
